<?php 
 include_once dirname(__FILE__)."/config.php";
 class personne_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_NO;
		 protected $_Civilite;
		 protected $_Titre;
		 protected $_Nom;
		 protected $_Prenom;
		 protected $_CIN;
		 protected $_login;
		 protected $_MotPasse;
		 protected $_Mail;
		 protected $_AdressePostale;
		 protected $_NumTelephone;
		 protected $_NumFax;
		 protected $_NumMobile;
		 protected $_CategorieUsager;
		 protected $_CategoriePrincipaleUsager;
		 protected $_IdentifiantInstitutionnel;
		 protected $_OrganismeRattachement;
		 protected $_LMD;
		 protected $_Discipline;
		 public function get_name_table(){ return "personne";}
		 public function get_name_NO(){ return "NO";}
		 public function get_name_Civilite(){ return "Civilite";}
		 public function get_name_Titre(){ return "Titre";}
		 public function get_name_Nom(){ return "Nom";}
		 public function get_name_Prenom(){ return "Prenom";}
		 public function get_name_CIN(){ return "CIN";}
		 public function get_name_login(){ return "login";}
		 public function get_name_MotPasse(){ return "MotPasse";}
		 public function get_name_Mail(){ return "Mail";}
		 public function get_name_AdressePostale(){ return "AdressePostale";}
		 public function get_name_NumTelephone(){ return "NumTelephone";}
		 public function get_name_NumFax(){ return "NumFax";}
		 public function get_name_NumMobile(){ return "NumMobile";}
		 public function get_name_CategorieUsager(){ return "CategorieUsager";}
		 public function get_name_CategoriePrincipaleUsager(){ return "CategoriePrincipaleUsager";}
		 public function get_name_IdentifiantInstitutionnel(){ return "IdentifiantInstitutionnel";}
		 public function get_name_OrganismeRattachement(){ return "OrganismeRattachement";}
		 public function get_name_LMD(){ return "LMD";}
		 public function get_name_Discipline(){ return "Discipline";}
		 public function set_NO($parametre){  $this->_NO=$parametre;}	
		 public function set_Civilite($parametre){  $this->_Civilite=$parametre;}	
		 public function set_Titre($parametre){  $this->_Titre=$parametre;}	
		 public function set_Nom($parametre){  $this->_Nom=$parametre;}	
		 public function set_Prenom($parametre){  $this->_Prenom=$parametre;}	
		 public function set_CIN($parametre){  $this->_CIN=$parametre;}	
		 public function set_login($parametre){  $this->_login=$parametre;}	
		 public function set_MotPasse($parametre){  $this->_MotPasse=$parametre;}	
		 public function set_Mail($parametre){  $this->_Mail=$parametre;}	
		 public function set_AdressePostale($parametre){  $this->_AdressePostale=$parametre;}	
		 public function set_NumTelephone($parametre){  $this->_NumTelephone=$parametre;}	
		 public function set_NumFax($parametre){  $this->_NumFax=$parametre;}	
		 public function set_NumMobile($parametre){  $this->_NumMobile=$parametre;}	
		 public function set_CategorieUsager($parametre){  $this->_CategorieUsager=$parametre;}	
		 public function set_CategoriePrincipaleUsager($parametre){  $this->_CategoriePrincipaleUsager=$parametre;}	
		 public function set_IdentifiantInstitutionnel($parametre){  $this->_IdentifiantInstitutionnel=$parametre;}	
		 public function set_OrganismeRattachement($parametre){  $this->_OrganismeRattachement=$parametre;}	
		 public function set_LMD($parametre){  $this->_LMD=$parametre;}	
		 public function set_Discipline($parametre){  $this->_Discipline=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_NO(){ return $this->_NO;}
		 public function get_Civilite(){ return $this->_Civilite;}
		 public function get_Titre(){ return $this->_Titre;}
		 public function get_Nom(){ return $this->_Nom;}
		 public function get_Prenom(){ return $this->_Prenom;}
		 public function get_CIN(){ return $this->_CIN;}
		 public function get_login(){ return $this->_login;}
		 public function get_MotPasse(){ return $this->_MotPasse;}
		 public function get_Mail(){ return $this->_Mail;}
		 public function get_AdressePostale(){ return $this->_AdressePostale;}
		 public function get_NumTelephone(){ return $this->_NumTelephone;}
		 public function get_NumFax(){ return $this->_NumFax;}
		 public function get_NumMobile(){ return $this->_NumMobile;}
		 public function get_CategorieUsager(){ return $this->_CategorieUsager;}
		 public function get_CategoriePrincipaleUsager(){ return $this->_CategoriePrincipaleUsager;}
		 public function get_IdentifiantInstitutionnel(){ return $this->_IdentifiantInstitutionnel;}
		 public function get_OrganismeRattachement(){ return $this->_OrganismeRattachement;}
		 public function get_LMD(){ return $this->_LMD;}
		 public function get_Discipline(){ return $this->_Discipline;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 personne(
			Civilite,
			Titre,
			Nom,
			Prenom,
			CIN,
			login,
			MotPasse,
			Mail,
			AdressePostale,
			NumTelephone,
			NumFax,
			NumMobile,
			CategorieUsager,
			CategoriePrincipaleUsager,
			IdentifiantInstitutionnel,
			OrganismeRattachement,
			LMD,
			Discipline)
 VALUES(
			'".$this->_Civilite."',
			'".$this->_Titre."',
			'".$this->_Nom."',
			'".$this->_Prenom."',
			'".$this->_CIN."',
			'".$this->_login."',
			'".$this->_MotPasse."',
			'".$this->_Mail."',
			'".$this->_AdressePostale."',
			'".$this->_NumTelephone."',
			'".$this->_NumFax."',
			'".$this->_NumMobile."',
			'".$this->_CategorieUsager."',
			'".$this->_CategoriePrincipaleUsager."',
			'".$this->_IdentifiantInstitutionnel."',
			'".$this->_OrganismeRattachement."',
			'".$this->_LMD."',
			'".$this->_Discipline."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_Civilite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Civilite='".$this->_Civilite."'";
}
if(!empty($this->_Titre)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Titre='".$this->_Titre."'";
}
if(!empty($this->_Nom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Nom='".$this->_Nom."'";
}
if(!empty($this->_Prenom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Prenom='".$this->_Prenom."'";
}
if(!empty($this->_CIN)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CIN='".$this->_CIN."'";
}
if(!empty($this->_login)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
login='".$this->_login."'";
}
if(!empty($this->_MotPasse)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
MotPasse='".$this->_MotPasse."'";
}
if(!empty($this->_Mail)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Mail='".$this->_Mail."'";
}
if(!empty($this->_AdressePostale)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
AdressePostale='".$this->_AdressePostale."'";
}
if(!empty($this->_NumTelephone)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumTelephone='".$this->_NumTelephone."'";
}
if(!empty($this->_NumFax)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumFax='".$this->_NumFax."'";
}
if(!empty($this->_NumMobile)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumMobile='".$this->_NumMobile."'";
}
if(!empty($this->_CategorieUsager)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CategorieUsager='".$this->_CategorieUsager."'";
}
if(!empty($this->_CategoriePrincipaleUsager)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CategoriePrincipaleUsager='".$this->_CategoriePrincipaleUsager."'";
}
if(!empty($this->_IdentifiantInstitutionnel)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
IdentifiantInstitutionnel='".$this->_IdentifiantInstitutionnel."'";
}
if(!empty($this->_OrganismeRattachement)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
OrganismeRattachement='".$this->_OrganismeRattachement."'";
}
if(!empty($this->_LMD)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
LMD='".$this->_LMD."'";
}
if(!empty($this->_Discipline)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Discipline='".$this->_Discipline."'";
}
$sql="UPDATE 
personne SET 
 ".$sql."
								WHERE NO ='".$this->_NO."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
personne 
 
									WHERE NO ='".$this->_NO."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
personne ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		NO,
		Civilite,
		Titre,
		Nom,
		Prenom,
		CIN,
		login,
		MotPasse,
		Mail,
		AdressePostale,
		NumTelephone,
		NumFax,
		NumMobile,
		CategorieUsager,
		CategoriePrincipaleUsager,
		IdentifiantInstitutionnel,
		OrganismeRattachement,
		LMD,
		Discipline
 FROM 
 personne";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_NO=$row->NO;
		$this->_Civilite=$row->Civilite;
		$this->_Titre=$row->Titre;
		$this->_Nom=$row->Nom;
		$this->_Prenom=$row->Prenom;
		$this->_CIN=$row->CIN;
		$this->_login=$row->login;
		$this->_MotPasse=$row->MotPasse;
		$this->_Mail=$row->Mail;
		$this->_AdressePostale=$row->AdressePostale;
		$this->_NumTelephone=$row->NumTelephone;
		$this->_NumFax=$row->NumFax;
		$this->_NumMobile=$row->NumMobile;
		$this->_CategorieUsager=$row->CategorieUsager;
		$this->_CategoriePrincipaleUsager=$row->CategoriePrincipaleUsager;
		$this->_IdentifiantInstitutionnel=$row->IdentifiantInstitutionnel;
		$this->_OrganismeRattachement=$row->OrganismeRattachement;
		$this->_LMD=$row->LMD;
		$this->_Discipline=$row->Discipline;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>